package org.wz.complex.work.kit.json;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.wz.complex.work.consts.PathConst;
import org.wz.complex.work.entity.auth.sysinfo.SysinfoMicro;
import org.wz.complex.work.entity.project.code.CodeVue;
import org.wz.complex.work.entity.project.generator.GeneratorVue;
import org.wz.complex.work.kit.code.GenVueKit;


import java.io.File;

import static org.wz.complex.work.consts.PathConst.DESKTOP;

public interface JsonKit {

    String NAME = "test2.json";

    public static <T> T file(String path, Class<T> clz) {
        JSONObject json = JSONUtil.readJSONObject(new File(path), CharsetUtil.CHARSET_UTF_8);
        T gen = json.toBean(clz);
        return gen;
    }

    public static void main(String[] args) {
        GeneratorVue vue = file(DESKTOP + NAME, GeneratorVue.class);
        CodeVue project = vue.getCodeVue();
        SysinfoMicro micro = vue.getSysinfoMicro();
        GenVueKit.gen(vue, project, micro);
    }

}
